﻿
using bpms.Dao;
using bpms.Models;

namespace bpms.Service
{
    /// <summary>
    /// 订单服务类
    /// </summary>
    public class OrderService
    {
        private readonly OrderDao orderDao;
        public OrderService(OrderDao dao)
        {
            orderDao = dao;
        }
        /// <summary>
        /// 获取所有订单
        /// </summary>
        /// <returns></returns>
        public List<OrderView> GetAll(string keyword)
        {
            return orderDao.GetAll(keyword);
        }

        /// <summary>
        /// 获取指定顾客所有订单
        /// </summary>
        /// <param name="buyerId"></param>
        /// <returns></returns>
        public List<OrderView> GetBuyerAll(int buyerId,string keyword)
        {
            return orderDao.GetBuyerAll(buyerId,keyword);
        }

        /// <summary>
        /// 获取指定订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public OrderView GetById(int id)
        {
            return orderDao.GetById(id);
        }

        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public int Add(Order order)
        {
            return orderDao.Add(order);
        }

        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int id)
        {
            return orderDao.Delete(id);
        }
    }
}
